package com.wf.ew.orderB.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.User;
import com.wf.ew.orderB.biz.CustomerBiz;
import com.wf.ew.orderB.model.Customer;
import com.wf.ew.orderB.service.CustomerService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2020-04-13 13:56:30
 * @version ：1.0
 */
@Service
public class CustomerServiceImpl implements CustomerService {

	@Autowired
	private CustomerBiz customerBiz;

	@Override
	public String list(PageResult<T> page, Customer customer, User loginUser) {
		return customerBiz.list(page,customer,loginUser);
	}
	
	@Override
	public List<Customer> list(Customer customer, User loginUser) {
		return customerBiz.list(customer,loginUser);
	}

	@Override
	public List<Customer> customerListAll() {
		return customerBiz.customerListAll();
	}

	@Override
	public Customer getById(Customer customer) {
		return customerBiz.getById(customer);
	}

	@Transactional
	@Override
	public JsonResult add(Customer customer, User loginUser) {
		if (customerBiz.add(customer, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(Customer customer, User loginUser) {
		if (customerBiz.update(customer, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(Customer customer, User loginUser) {
		if (customerBiz.delete(customer, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
